package com.itheima.utils;

import java.util.Date;

public class TimeUtil {
    public static String getTimeUtil(Date strTime1, Date strTime2) {
        //格式日期格式，在此我用的是"2018-01-24 19:49:50"这种格式

        try {
            long l = strTime1.getTime() - strTime2.getTime();       //获取时间差
            long day = l / (24 * 60 * 60 * 1000);
            long hour = (l / (60 * 60 * 1000) - day * 24);
            long min = ((l / (60 * 1000)) - day * 24 * 60 - hour * 60);
            return hour + "时" + min + "分";
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
    }

    public static void main(String[] args) {
    }
}
